﻿using System;
using System.Collections.Generic;
using System.Xml;

namespace ConfigManager.Core.Instructions
{
    public class EmbeddedSectionInstruction : XmlInstruction
    {
        private string _data;

        /// <summary>
        /// Gets or sets the data.
        /// </summary>
        /// <value>The data.</value>
        public string Data
        {
            get { return _data; }
            set { _data = value; }
        }


        /// <summary>
        /// Initializes a new instance of the <see cref="EmbeddedSectionInstruction"/> class.
        /// </summary>
        /// <param name="xmlDoc">The XML doc.</param>
        /// <param name="node">The node.</param>
        /// <param name="parameters">The parameters.</param>
        /// <param name="data">The data.</param>
        public EmbeddedSectionInstruction(XmlDocument xmlDoc, XmlNode node, IDictionary<string, string> parameters)
            : base ( xmlDoc, node, parameters)
        {

        }

        /// <summary>
        /// Runs this instruction.
        /// </summary>
        public override void Run()
        {
            if (PassesConditions())
                InsertXmlFragment(Data, Node, XmlDoc);

            base.Run();
        }
    }
}
